@extends("layouts.backend.webadmin")
@section('page-header')
<h1>
    <small>config</small>
</h1>
@endsection

@section('content')
<link rel="stylesheet" href="{{env('APP_ROOT')}}/assets/select2/css/select2.min.css">
<link rel="stylesheet" href="{{env('APP_ROOT')}}/css/protasklist.css">
<!-- Main content -->
<section class="content">
    <div class="row">
        <div class="col-xs-12">

            <div class="box">

                <div class="box-body">
                    @if($errors->any())
                        <ul class="alert alert-danger">
                            @foreach($errors->all() as $error)
                                <li>{{ $error }}</li>
                            @endforeach
                        </ul>
                    @endif
                    <form method="post" action="{{ URL::route('admin.projectmanage.updaterow') }}">
                        <input type="hidden" name="id" value="{{$item->id}}">
                        <div class="form-group">
                            <label for="name">项目名称</label>

                            <input value="{{$item->name}}" name="name" type="text" class="form-control" placeholder="项目名称">
                        </div>
                        <div class="form-group">
                            <label for="app_id">目标应用</label>
                            <input value="{{$item->app->name}}" name="app" type="text" class="form-control" placeholder="目标应用" disabled>
                        </div>
                        <div class="form-group">
                            <label for="app_id">应用详情</label>
                            <a href="{{route('qyapp.editpage',['id'=>$item->app->id])}}">编辑应用</a>
                            <div class="container-fluid">
                                <table class="table table-bordered table-striped">
                                    <tbody>
                                    <tr>
                                        <td>所属企业:</td>
                                        <td>{{$item->app->ogz}}</td>
                                    </tr>
                                    <tr>
                                        <td>联系人信息:</td>
                                        <td>{{$item->app->userStr}}</td>
                                    </tr>
                                    <tr>
                                        <td>用户量预估:</td>
                                        <td>@if($item->app->uet){{$item->app->uet}}万@endif</td>
                                    </tr>
                                    <tr>
                                        <td>应用类型:</td>
                                        <td>{{$item->app->typeStr}}</td>
                                    </tr>
                                    <tr>
                                        <td>是否对外:</td>
                                        <td>{{$item->app->isforeignStr}}</td>
                                    </tr>
                                    <tr>
                                        <td>预估价值:</td>
                                        <td>@if($item->app->etv){{$item->app->etv}}万@endif</td>
                                    </tr>
                                    <tr>
                                        <td>域名/IP地址:</td>
                                        <td>{{$item->app->address}}</td>
                                    </tr>
                                    <tr>
                                        <td>开放端口和服务:</td>
                                        <td>{{$item->app->ops}}</td>
                                    </tr>

                                    <tr>
                                        <td>中间件和服务及版本信息:</td>
                                        <td>{{$item->app->msv}}</td>
                                    </tr>
                                    <tr>
                                        <td>开发语言和使用第三方库及版本信息:</td>
                                        <td>{{$item->app->lvv}}</td>
                                    </tr>
                                    <tr>
                                        <td>测试账号:</td>
                                        <td>{{$item->app->ut}}</td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="form-group">
                            <label>测试记录</label>
                            <div class="container-fluid">
                                <table id="table_record" class="table table-bordered table-striped">
                                    <thead>
                                    </thead>
                                    <tbody>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="form-group">
                            <label>发现漏洞</label>
                            <div class="container-fluid">
                                <table id="table_discover_vul" class="table table-bordered table-striped">
                                    <thead>
                                    </thead>
                                    <tbody>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="form-group">
                            <label>历史漏洞</label>
                            <div class="container-fluid">
                                <table id="table_history_vul" class="table table-bordered table-striped">
                                    <thead>
                                    </thead>
                                    <tbody>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="pcp">责任人</label>
                            <select class="form-control select2" multiple aria-hidden="true" name="pcp[]">
                            <option>--责任人--</option>
                            @foreach($pcp as $pc)
                                    @foreach($item->pcpIds as $pcId)
                                <option @if($pcId == $pc->id)) selected @endif value="{{$pc->id}}">{{$pc->name}}</option>
                                    @endforeach
                            @endforeach
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="started_at">开始时间</label>

                            <input value="{{date('m/d/Y',strtotime($item->started_at))}}" name="started_at" type="text" class="form-control data-picker" placeholder="Started_at">
                        </div>
                        <div class="form-group">
                            <label for="ended_at">结束时间</label>

                            <input value="{{date('m/d/Y',strtotime($item->ended_at))}}" name="ended_at" type="text" class="form-control data-picker" placeholder="Ended_at">
                        </div>
                        <div class="form-group">
                            <label for="status">状态</label>
                            <select class="form-control" id="status" name="status">
                                @foreach($statusArr as $id => $status)
                                    <option value="{{$id}}" @if($id==$item->status) selected @endif>{{$status}}</option>
                                @endforeach
                            </select>
                        </div>
                        {!! csrf_field() !!}
                        <button type="submit" class="btn btn-primary projectmanage-update">提交</button>
                    </form>
                </div>
            </div>
        </div>
    </div>
</section>
@stop
@section('javascript-end')
<script src="{{env('APP_ROOT')}}/assets/select2/js/select2.min.js"></script>
<script>
    $(function () {
        console.log('welcome to ck page.');
        //日历控件
        $('.data-picker').datepicker({
            autoclose: true
        });
        //下拉筛选
        $('.select2').select2({"border-radius":'0px'});
        var table_record = $('#table_record').DataTable({
            //调整结构
            "dom": '<"dataTables_filter">rtp',
            "autoWidth":true,
            //国际化
            'oLanguage'   :{
                'sUrl'    : '{{env("APP_ROOT")}}/assets/bootstrap/js/zh_cn.json'
            },
            "bSort": false,//禁止排序
            "pageLength":10,
            "processing": true,
            //开启服务器模式
            serverSide: true,
            ajax: {
                //指定数据源
                url: "{{route('admin.projectmanage.recordlist')}}",
                type: "GET",
                data: function(d){
                    delete d.columns;
                    d.app_id = "{{$item->app->app_id}}";
                    d.id = "{{$item->id}}";
                    return d;
                }
            },
            //data值对应数据库字段名
            columns: [
                {
                    'title':'编号',
                    'data':'pro_number'
                },
                {
                    'title':'项目标题',
                    'data':'name',
                    "render": function(data,type,row,meta) {
                        return '<a target="_blank" href="{{route('admin.projectmanage.detail')}}?id='+row['id']+'">'+data+'</a>'
                    }
                },
                {
                    'title':'开始时间',
                    'data':'started_at'
                },
                {
                    'title':'结束时间',
                    'data':'ended_at'
                },
                {
                    "title":"状态",
                    'data':'statusStr'
                },
                {
                    "title":"漏洞数",
                    'data':'vul_num'
                }
            ],
            columnDefs: [{
                "targets": "_all",
                "render": $.fn.dataTable.render.text()
            }]
        });
        var table_discover_vul = $('#table_discover_vul').DataTable({
            //调整结构
            "dom": '<"dataTables_filter">rtp',
            "autoWidth":true,
            //国际化
            'oLanguage'   :{
                'sUrl'    : '{{env("APP_ROOT")}}/assets/bootstrap/js/zh_cn.json'
            },
            "bSort": false,//禁止排序
            "pageLength":10,
            "processing": true,
            //开启服务器模式
            serverSide: true,
            ajax: {
                //指定数据源
                url: "{{route('admin.projectmanage.discovervul')}}",
                type: "GET",
                data: function(d){
                    delete d.columns;
                    d.id = "{{$item->id}}";
                    return d;
                }
            },
            //data值对应数据库字段名
            columns: [
                {
                    "title":"编号",
                    'data':'vuls_number'
                },
                {
                    "title":"标题",
                    'data':'title',
                    "render": function(data,type,row,meta) {
                        return '<a target="_blank" href="{{route("admin.flaw.vulsdetail")}}?id='+row['id']+'">'+data+'</a>'
                    }
                },
                {
                    "title":"等级",
                    'data':'lname'
                },
                {
                    "title":"类型",
                    'data':'cname'
                },
                {
                    "title":"状态",
                    'data':'statusStr'
                },
                {
                    "title":"发现者",
                    'data':'uname'
                }
            ],
            columnDefs: [{
                "targets": "_all",
                "render": $.fn.dataTable.render.text()
            }]
        });
        var table_history_vul = $('#table_history_vul').DataTable({
            //调整结构
            "dom": '<"dataTables_filter">rtp',
            "autoWidth":true,
            //国际化
            'oLanguage'   :{
                'sUrl'    : '{{env("APP_ROOT")}}/assets/bootstrap/js/zh_cn.json'
            },
            "bSort": false,//禁止排序
            "pageLength":10,
            "processing": true,
            //开启服务器模式
            serverSide: true,
            ajax: {
                //指定数据源
                url: "{{route('admin.projectmanage.historyvul')}}",
                type: "GET",
                data: function(d){
                    delete d.columns;
                    d.id = "{{$item->id}}";
                    return d;
                }
            },
            //data值对应数据库字段名
            columns: [
                {
                    "title":"编号",
                    'data':'vuls_number'
                },
                {
                    "title":"标题",
                    'data':'title',
                    "render": function(data,type,row,meta) {
                        return '<a target="_blank" href="{{route("admin.flaw.vulsdetail")}}?id='+row['id']+'">'+data+'</a>'
                    }
                },
                {
                    "title":"等级",
                    'data':'lname'
                },
                {
                    "title":"类型",
                    'data':'cname'
                },
                {
                    "title":"状态",
                    'data':'statusStr'
                },
                {
                    "title":"发现者",
                    'data':'uname'
                }
            ],
            columnDefs: [{
                "targets": "_all",
                "render": $.fn.dataTable.render.text()
            }]
        });
    });
</script>
@endsection
